<!doctype html>
<html lang="zh-Hans-CN">

<head>
    <meta charset="utf-8"/>
    <meta name="format-detection" content="telephone=no"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0, viewport-fit=cover">
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <title>报名介绍</title>
    <link rel="stylesheet" href="/ui/mobile/iconfont/iconfont.css">
    <link rel="stylesheet" href="/ui/mobile/css/ui.all.css"/>
    <link rel="stylesheet" href="/ui/mobile/css/style.css" type="text/css"/>
</head>

<body>
<div class="c-main">
    <header class="detail-header">
        <p data-name="questionTitle" class="tit"></p>
        <p data-name="price" class="price"></p>
    </header>
    <section class="detail-tabcont">
        <div data-name="adImgUrl"></div>
    </section>

    <div class="fixed-bs-box">
        <div class="fixed-bs order-fixed-bot">
            <p class="bot-price">合计：<span data-name="price"></span></p>
            <a data-btn="submit" href="javascript:" class="bot-btn">立即预约</a>
        </div>
    </div>
</div>
<script type="text/javascript" src="/m/public/all.ui.js"></script>
<script src="/ui/mobile/iconfont/iconfont.js"></script>
<script src="/m/public/util.js"></script>

<script type="text/javascript">
    const {questionId} = $.getPageParam();
    if (!questionId) {
        location.href = "/m/error.html?" + $.param({msg: "问卷ID不能为空", back: window.location.href});
    }

    getQuestionDetails({questionId}, ({Code, Message, Result: data}) => {
        if (Code !== 10000) {
            location.href = "/m/error.html?" + $.param({msg: Message, back: window.location.href});
        }

        const {adImgUrl, price, questionTitle} = data;

        document.title = questionTitle;
        $('[data-name="questionTitle"]').text(questionTitle);
        $('[data-name="price"]').text("¥" + (price / 100).toFixed(2));
        $('[data-name="adImgUrl"]').html(`<img src="${adImgUrl}" alt="" class="detail-banner">`)

        const $submitBtn = $('[data-btn="submit"]');
        $submitBtn.on("click", () => {
            location.href = "/m/question/form.html?" + $.param({questionId})
        })
    })

    function getQuestionDetails(param, callback = Function()) {
        return $.sApi({
            data: param,
            url: "/api/Question/getQuestionDetails"
        }, callback)
    }

</script>

</body>
</html>